﻿using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class Data_Route : Data
    {
        #region[Route_Insert]
        public void Route_Insert(Route data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Route_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Route_Name",data.Route_Name);
                cmd.Parameters.Add("@Departure",data.Departure);
                cmd.Parameters.Add("@Destination",data.Destination);
                cmd.Parameters.Add("@Distance",data.Distance);

                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[Route_Update]
        public void Route_Update(Route data)
        {
            using (SqlCommand cmd = new SqlCommand("sp_Route_Update", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Route_Name", data.Route_Name);
                cmd.Parameters.Add("@Departure", data.Departure);
                cmd.Parameters.Add("@Destination", data.Destination);
                cmd.Parameters.Add("@Distance", data.Distance);

                cmd.ExecuteNonQuery();
            }
        }
        #endregion

        #region[Route_GetByAll]
        public DataTable Route_GetAll()
        {
            using (SqlCommand cmd = new SqlCommand("sp_Route_GetAll", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                DataTable dt = new DataTable();
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);

                return dt;
            }
        }
        #endregion
    }
}
